<?php
// +----------------------------------------------------------------------
// | B5Yii2CMF V3.0 [快捷通用基础管理开发平台]
// +----------------------------------------------------------------------
// | Author: 冰舞 <357145480@qq.com>
// +----------------------------------------------------------------------
declare (strict_types=1);

namespace api\utils\libs;


use common\models\system\AppToken;

/**
 * 设置token和查询token
 * Trait TraitToken
 * @package api\modules\admin\utils
 */
trait TraitToken
{
    // 查询token信息
    protected function getToken(string $token = '', string $type = 'admin', string $plat = 'web', bool $autoRefresh = true): ?AppToken
    {
       return TokenMethod::getToken($token, $type, $plat, $autoRefresh);
    }

    // 设置token
    protected function setToken($id, string $type = 'admin', string $plat = 'web', string $extend = ''): string
    {
        return TokenMethod::setToken($id, $type, $plat, $extend);
    }

    // 删除某个用户token
    protected function clearToken(int $user_id, string $plat, string $type)
    {
        TokenMethod::clearToken($user_id, $plat, $type);
    }

    protected function clearTokenByUserName(string $username, string $plat, string $type)
    {
       TokenMethod::clearTokenByUserName($username, $plat, $type);
    }
}